<%--   /home/araaya/dev/projects/eLand_new/src/main/webapp/WEB-INF/pages/landAlienation/initLandAlieanationApplicationForms/initNewAlienationApplication.jsp
  @author Duminda Dharmakeerthi
  @author Supun Viraj Rathnayaka
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script src="${pageContext.request.contextPath}/js/validateApplication.js" type="text/javascript"></script>
<script type="text/javascript">
    var mode = '<s:property value="editMode"/>';
    var personType = '<s:property value="holder.holderType"/>';
    $(function () {
        if (mode == 0 || mode == 1) {
            validateApplication();
        }

        if (mode == 2) { //for approve mode
            disableFields(new Array(
                    'submitDate',
                    'alienationMethodSelectedList-1',
                    'alienationMethodSelectedList-2',
                    'alienationMethodSelectedList-3',
                    'gnDivisionId',
                    'districtId',
                    'dsDivisionId',
                  'purposeId',
                 'residencialTypeListId',
                    'addChild'
                    ));
            disableFields(new Array('applicantType0', 'applicantType1'));
        }
    });
    $(function() {
        $('#personDetails').hide();
        $('#instituteDetails').hide();

        $('#applicantType0').bind('click', function() {
            $('#personDetails').hide();
            $('#instituteDetails').show();
            disableFields(fieldIds_person);
            showFields(fieldIds_institute);

        });
        $('#applicantType1').bind('click', function() {

            $('#personDetails').show();
            $('#instituteDetails').hide();
            disableFields(fieldIds_institute);
            showFields(fieldIds_person);

        });
        if ($('#applicantType0').is(':checked')) {

            $('#personDetails').hide();
            $('#instituteDetails').show();
            disableFields(fieldIds_person);
            showFields(fieldIds_institute);

        } else if ($('#applicantType1').is(':checked')) {

            $('#personDetails').show();
            $('#instituteDetails').hide();
            disableFields(fieldIds_institute);
            showFields(fieldIds_person);
        }
    });

    $(function() {
        $('select#districtId').bind('change', function(evt1) {
            var id = $("select#districtId").attr("value");
            $.getJSON('${pageContext.request.contextPath}/common/DivisionLookupService', {id:id,mode:2},
                     function(data) {
                         //var options1 = '<option value="0"> - Select  - </option> ';
                         var options1 = '<option value="0">' + $('#select').val()  + '</option> ';
                         var ds = data.dsDivisionList;
                         for (var i = 0; i < ds.length; i++) {
                             options1 += '<option value="' + ds[i].optionValue + '">' + ds[i].optionDisplay + '</option>'

                         }
                         $("select#dsDivisionId").html(options1);
                         var options2 = '<option value="0">' + $('#select').val()  + '</option> ';
                         $("select#gnDivisionId").html(options2);
                     });
        });
    });

    $(function() {
        $('select#dsDivisionId').bind('change', function(evt1) {
            var id = $("select#dsDivisionId").attr("value");
            $.getJSON('${pageContext.request.contextPath}/common/DivisionLookupService', {id:id,mode:3},
                     function(data) {
                         //var options1 = '<option value="0"> - Select  - </option> ';
                         var options1 = '<option value="0">' + $('#select').val()  + '</option> ';
                         var ds = data.gnDivisionList;
                         for (var i = 0; i < ds.length; i++) {
                             options1 += '<option value="' + ds[i].optionValue + '">' + ds[i].optionDisplay + '</option>'

                         }
                         $("select#gnDivisionId").html(options1);
                     });

        });
    });


</script>

<s:if test="editMode!=0">
    <s:if test="#session.userGroup !='slc'">
        <div id="land-registration-module-home-title" class="module-home-title">
            <s:include value="../alienationApplicationNavigationInit.jsp"/>
        </div>

    </s:if>
</s:if>

<s:if test="#session.userGroup =='onla'">
    <div id="main-content-onla">
        <div class="module-home-title">
            
                <div id="back-button1-onla" align="right">
                    <s:submit type="input" value="%{getText('back.label')}" onclick="goBack();"/>
                </div>
        </div>
    </div>
    </s:if>


<div id="init-land-permits-application-outer" class="form-outer">
    <h3><s:label value="%{getText('initial_land_application.label')}"/> -
        <s:label value="%{getText('new_alienation.label')}"/></h3>

    <hr/>
    <div align="left" style="color:red">
        <s:actionerror/>
        <s:actionmessage/>
    </div>
    <s:form method="POST" id="gov-land-init-permit-application-form"
            onsubmit="javascript:return (validateFormForInputDataSyntaxErrors('gov-land-init-permit-application-form') && resetIncome() && selectList())">
        <fieldset class="submit-date-fieldset-style">
            <table class="submited-date-table">
                <tr>
                    <td><s:label value="%{getText('submit_date.label')}" cssClass="mandatory-field"/><s:label
                            value="%{getText('date_format.label')}" cssClass="date-format"/></td>
                    <td><s:textfield id="submitDate" name="landApplication.submitDate"
                                     onKeyPress="return dateNumbersOnly(event,true)"/></td>
                </tr>
                <tr>
                    <td><s:label value="%{getText('alienation_methods.label')}" cssClass="mandatory-field"/></td>
                    <td><s:checkboxlist id="alienationMethodSetId" list="alienationMethodSet"
                                        name="alienationMethodSelectedList"
                                        value="amSelectedList" theme="checkbox-theme"/></td>
                    <s:hidden name="newAlienation" value="1"/>
                </tr>
            </table>
        </fieldset>
        <div id="tabs">
            <ul>
                <li><s:a href="#land-permit-details"><s:label
                        value="%{getText('details_of_applicant.label')}"/></s:a></li>
                <li><s:a href="#landAlienationDetails"><s:label value="%{getText('details_of_land.label')}"/></s:a></li>
                <li><s:a href="#otherDetails"><s:label value="%{getText('other_details.label')}"/></s:a></li>
            </ul>
            <div class="fieldset-style" id="land-permit-details">
                <table class="width-100">
                    <tr>
                        <td align="center" colspan="4">
                            <s:radio id="applicantType" name="holder.holderType"
                                     list="#@java.util.HashMap@{'1':getText('person.label'),'0':getText('institute.label')}"/>

                        </td>
                    </tr>
                </table>
                <table class="width-100" id="division">
                    <s:if test="viewMode">
                        <tr>
                            <td><s:label value="%{getText('district.label')}"/></td>
                            <td><s:textfield id="districtId" name="districtName" cssClass="width-200-px"
                                             disabled="true"/></td>
                            <td><s:label value="%{getText('ds_division.label')}"/></td>
                            <td><s:textfield id="dsDivisionId" name="dsDivisionName" cssClass="width-200-px"
                                             disabled="true"/></td>
                        </tr>
                        <tr>
                            <td><s:label value="%{getText('gn_division.label')}"/><span class="mandatory-field"></span>
                            </td>
                            <td>
                                <s:textfield id="gnDivisionId" name="holder.gnDivision.name" cssClass="width-200-px"/>
                            </td>
                        </tr>
                    </s:if>
                    <s:else>
                        <tr>
                            <td><s:label value="%{getText('district.label')}"/></td>
                            <td><s:select id="districtId" name="districtId" list="districtListAll"
                                          headerKey="0" headerValue="%{getText('select.label')}"
                                          cssClass="width-200-px"/></td>
                            <td><s:label value="%{getText('ds_division.label')}"/></td>
                            <td><s:select id="dsDivisionId" name="dsDivisionId" list="dsDivisionList"
                                          headerKey="0"
                                          headerValue="%{getText('select.label')}" cssClass="width-200-px"/></td>
                        </tr>
                        <tr>
                            <td><s:label value="%{getText('gn_division.label')}"/><span class="mandatory-field"></span>
                            </td>
                            <td>
                                <s:select id="gnDivisionId" name="holder.gnDivision.id" list="gnDivisionList"
                                          headerKey="0" headerValue="%{getText('select.label')}"
                                          cssClass="width-200-px"/>
                            </td>
                        </tr>
                    </s:else>
                </table>
                <table id="instituteDetails" class="width-100">
                    <tr>
                        <td colspan="4">
                            <s:include value="../instituteDetails.jsp"/>
                        </td>
                    </tr>
                </table>
                <table id="personDetails" class="width-100">
                    <tr>
                        <td colspan="4">
                            <s:include value="../personalDetails.jsp"/>
                        </td>
                    </tr>

                </table>
            </div>
            <div class="fieldset-style" id="landAlienationDetails">
                <table class="width-100">
                    <s:include value="../landAlienationDetails.jsp"/>
                </table>
            </div>
            <div class="fieldset-style" id="otherDetails">
                <table class="width-100">
                    <tr>
                        <td><s:label value="%{getText('relationship_to_the_current_residency.label')}"/></td>
                        <td><s:select headerKey="-1" headerValue="%{getText('select.label')}"
                                      list="#@java.util.HashMap@{'0':getText('house_of_relative.option'),'1':getText('parents_house.option'),
            '2':getText('rent.option'),'3':getText('illegal_house.option'),'4':getText('temporary_house.option')}"
                                      name="landApplication.residencialType" id="residencialTypeListId"
                                      cssClass="width-180-px"/></td>
                    </tr>

                    <tr>
                        <td><s:label value="%{getText('purpose_of_the_requesting_land')}"/></td>
                        <td><s:select id="purposeId" name="landApplication.landUsage.id"
                                      list="purposeList" headerKey="-1" headerValue="%{getText('select.label')}"/></td>
                    </tr>
                </table>

            </div>
        </div>
        <hr/>
        <s:hidden id="edit_mode" name="editMode"/>
        <s:include value="initFormSubmitButton.jsp"/>

        <%--<s:include value="../approveRejectButton.jsp"/>--%>
    </s:form>
</div>

<s:hidden id="pls_enter_applicant_name" value="%{getText('pls_enter_applicant_name')}"/>
<s:hidden id="pls_enter_submit_date" value="%{getText('pls_enter_submit_date')}"/>
<s:hidden id="pls_enter_applicant_address" value="%{getText('pls_enter_applicant_address')}"/>
<s:hidden id="pls_enter_valid_email" value="%{getText('pls_enter_valid_email')}"/>
<s:hidden id="pls_enter_valid_phone_No" value="%{getText('pls_enter_valid_phone_No')}"/>
<s:hidden id="pls_enter_valid_NIC_No" value="%{getText('pls_enter_valid_NIC_No')}"/>
<s:hidden id="pls_enter_annual_income" value="%{getText('pls_enter_annual_income')}"/>
<s:hidden id="pls_enter_valid_annual_income" value="%{getText('pls_enter_valid_annual_income')}"/>
<s:hidden id="applicant_age_validate" value="%{getText('applicant_age_validate.label')}"/>
<s:hidden id="pls_enter_the_applicant_dob" value="%{getText('pls_enter_the_applicant_dob.label')}"/>
<s:hidden id="pls_enter_valid_value" value="%{getText('pls_enter_valid_value')}"/>
<s:hidden id="pls_enter_children_name" value="%{getText('pls_enter_children_name.label')}"/>
<s:hidden id="pls_select_nationality" value="%{getText('pls_select_nationality.label')}"/>
<s:hidden id="pls_select_applicant_type" value="%{getText('pls_select_applicant_type.label')}"/>
<s:hidden id="pls_select_gnDivision" value="%{getText('pls_select_gnDivision.label')}"/>
<s:hidden id="select" value="%{getText('select.label')}"/>


